﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RegisterCodeGenerator
{
    public class Register
    {
        public string Address { get; set; }
        public string Name { get; set; }
        public string Length { get; set; }
        public List<BitMask> BitMasks { get; set; }

        public Register(string[] items)
        {
            BitMasks = new List<BitMask>();
            if (items[0].Length == 1) //1:Address
            {
                Address = "0x0" + items[0];
            }
            else
            {
                Address = "0x" + items[0];
            }

            Name = items[1];
            if (!string.IsNullOrEmpty(items[2]))// bits value not empty, this is a register without bitmask
            {
                Length = ((int.Parse(items[2].Split(':')[0]) + 1) / 8).ToString(); //usually  (39+1)/8=5 bytes
            }
            else
            {
                Length = "1";
            }
        }
    }
}
